package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhCorporation;
import com.ruoyi.xh.service.IXhCorporationService;

/**
 * 市场/产品/总部Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "市场/产品/总部Controller",value = "市场/产品/总部Controller")
@RestController
@RequestMapping("/xh/corporation")
public class XhCorporationController extends BaseController {

    @Autowired
    private IXhCorporationService xhCorporationService;

    /**
     * 查询市场/产品/总部列表
     */
    @PreAuthorize("@ss.hasPermi('xh:corporation:list')")
    @GetMapping("/list")
    @ApiOperation("查询市场/产品/总部列表")
    public TablePageDataInfo<XhCorporation> list(XhCorporation xhCorporation) {
        return TablePageDataInfo.success(xhCorporationService.selectXhCorporationList(xhCorporation));
    }

    /**
     * 获取市场/产品/总部详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:corporation:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取市场/产品/总部详细信息")
    public CommentResult<XhCorporation> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhCorporationService.selectXhCorporationById(id));
    }

    /**
     * 新增市场/产品/总部
     */
    @PreAuthorize("@ss.hasPermi('xh:corporation:add')")
    @Log(title = "市场/产品/总部", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增市场/产品/总部")
    public CommentResult<XhCorporation> add(@RequestBody XhCorporation xhCorporation) {
            xhCorporationService.insertXhCorporation(xhCorporation);
        return CommentResult.success();
    }

    /**
     * 修改市场/产品/总部
     */
    @PreAuthorize("@ss.hasPermi('xh:corporation:edit')")
    @Log(title = "市场/产品/总部", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改市场/产品/总部")
    public CommentResult<XhCorporation> edit(@RequestBody XhCorporation xhCorporation) {
            xhCorporationService.updateXhCorporation(xhCorporation);
        return CommentResult.success();
    }

    /**
     * 删除市场/产品/总部
     */
    @PreAuthorize("@ss.hasPermi('xh:corporation:remove')")
    @Log(title = "市场/产品/总部", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除市场/产品/总部")
    public CommentResult<XhCorporation> remove(@PathVariable Long[] ids) {
            xhCorporationService.deleteXhCorporationByIds(ids);
        return CommentResult.success();
    }
}
